package com.laozhao.msas.util;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class Config {
	private static Properties ini = null;  
	  //设置INI文件  
	   static File file=new File("./bin/msas.ini");  
	   static {  
	       try {  
	           ini = new Properties ();  
	           //加载文件  
	           ini.load (new FileInputStream (file.getAbsoluteFile()));  
	       }catch (Exception ex) {  
	           ex.printStackTrace();  
	       }  
	   }  
	   private Config() {  
	   }  
	   /** 
	    * 读取INI信息 
	    * */  
	   public static String getConfig (String key) {  
	       if(!ini.containsKey (key)) {  
	           return "";  
	       }  
//	       String value = new String(value.getBytes("ISO8859-1"), encoding);

	       return ini.get(key).toString ();  
	   }  
	   /** 
	    * 修改INI信息 
	    * */  
	   public static void setIniKey (String key, String value) {  
	       if(!ini.containsKey (key)) {  
	           return;  
	       }  
	       ini.put (key, value);  
	   }  
//	   /** 
//	    * 保存INI信息 
//	    * */  
//	   public static void saveIni (String k[]) {  
//	       try {  
//	           FileWriter fw = new FileWriter (file);  
//	           BufferedWriter bw = new BufferedWriter (fw);  
//	           for (int i = 0; i < k.length; i++) {  
//	               bw.write (k[i] + "=" + getIniKey (k[i]));  
//	               bw.newLine ();  
//	           }  
//	           bw.close ();  
//	           fw.close ();  
//	       }catch (Exception ex) {  
//	           ex.printStackTrace();  
//	       }  
//	   }  


}
